/**
 * 👨‍💻 伟谭
 * 📅 2017/11/24
 */

#import "TWconvenienceOfServiceBodyCellTableViewCell.h"

@interface TWconvenienceOfServiceBodyCellTableViewCell()

@property(nonatomic,strong) UIImageView *imageViewHeader;

@property(nonatomic,strong) UILabel *lblTitle;

@property(nonatomic,strong) UILabel *lblAddressWithAppellation;

@property(nonatomic,strong) UIButton *btnBusinessLevelState;

@property(nonatomic,strong) UIImageView *imageVerticalLine;

@property(nonatomic,strong) UIButton *btnCallPhone;


@end

@implementation TWconvenienceOfServiceBodyCellTableViewCell

#pragma mark - Class method

#pragma mark - Life cycle

#pragma mark - Override
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if(self){
        
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        [self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        [self initializeViews];
        
    }
    
    return self;
}

- (void)setFrame:(CGRect)frame {
    
    frame.origin.y += 1;  // 让cell的y值增加1(根据自己需要分割线的高度来进行调整)
    frame.size.height -= 1; // 让cell的高度减1
    [super setFrame:frame]; // 别忘了重写父类方法
}


#pragma mark - Event response

#pragma mark - Protocol

#pragma mark <<#XXXDelegate#>>

#pragma mark - Public method

#pragma mark - Private method
- (void)initializeViews{
    
    UIImageView *imageViewHeader = [UIImageView new];
    imageViewHeader = [[UIImageView alloc]init];
    imageViewHeader.image = IMG(@"便民服务图");
 
    [self.contentView addSubview:imageViewHeader];
    _imageViewHeader = imageViewHeader;
    
    
    
    UILabel *lblTitle = [UILabel hj_labelWithText:@"重庆旺达专业小型居名 重庆旺达专业小型居名" textColor:nil font:FontL(13.5f) textAlignment:NSTextAlignmentLeft];
    lblTitle.numberOfLines = 2;
    lblTitle.lineBreakMode = NSLineBreakByCharWrapping;
    [self.contentView addSubview:lblTitle];
    _lblTitle = lblTitle;
    
    
    
    
    UIButton *btnBusinessLevelState = [UIButton hj_buttonWithTitle:@"优质商家" tintColor:[UIColor redColor] font:FontT(10.0f) touchUpInsideTarget:nil action:nil];
    btnBusinessLevelState.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    btnBusinessLevelState.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    
    btnBusinessLevelState.clipsToBounds = YES;
    btnBusinessLevelState.layer.cornerRadius = 4.0f;
    btnBusinessLevelState.layer.borderWidth =1.0f;
    btnBusinessLevelState.layer.borderColor = [UIColor redColor].CGColor;
    btnBusinessLevelState.contentEdgeInsets = UIEdgeInsetsMake(2.0, 4.0f, 4.0f, 2.0f);
    [self.contentView addSubview:btnBusinessLevelState];
    
    _btnBusinessLevelState = btnBusinessLevelState;
    
    
    
    UILabel *lblAddressWithAppellation = [UILabel hj_labelWithText:@"九龙坡-旺达搬家公司" textColor:[UIColor grayColor] font:FontT(10.0f) textAlignment:NSTextAlignmentLeft];
    lblAddressWithAppellation.numberOfLines = 1;
    [self.contentView addSubview:lblAddressWithAppellation];
    _lblAddressWithAppellation = lblAddressWithAppellation;
    
    UIButton *btnCallPhone = [UIButton hj_buttonWithType:UIButtonTypeCustom Image:IMG(@"电话")];
    [self.contentView addSubview:btnCallPhone];
    
    _btnCallPhone = btnCallPhone;
    
    UIImageView *imageVerticalLine = [UIImageView new];
    imageVerticalLine.image = [UIImage imageWithColor:LineColor size:CGSizeMake(2, 2)];
    imageViewHeader.contentMode = UIViewContentModeScaleToFill;
    [self.contentView addSubview:imageVerticalLine];
    _imageVerticalLine = imageVerticalLine;
    
    
   
    
    
    
    [imageViewHeader mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(10.0f);
        make.bottom.offset(-10.0f);
        make.left.offset(16.0f);
        make.width.equalTo(imageViewHeader.mas_height).multipliedBy(1.343f);
    }];
    
    [lblTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imageViewHeader.mas_right).offset(6.0f);
        make.right.equalTo(imageVerticalLine.mas_left).offset(-6.0f);
        make.top.equalTo(imageViewHeader);
    }];
    
    [lblAddressWithAppellation mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.equalTo(imageViewHeader.mas_right).offset(6.0f);
         make.right.equalTo(imageVerticalLine.mas_left).offset(-6.0f);
         make.bottom.equalTo(imageViewHeader.mas_bottom).offset(-6.0f);
    }];
    
    [btnBusinessLevelState mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(imageVerticalLine).offset(-8.0f);
        make.centerY.equalTo(lblAddressWithAppellation);
    }];
    
    [imageVerticalLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(16.0f);
        make.bottom.offset(-16.0f);
        make.width.offset(1.5f);
        make.right.equalTo(btnCallPhone.mas_left).offset(-6.0f);
    }];
    
    [btnCallPhone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0.0f);
        make.right.offset(-8.0f);
        make.width.height.offset(50.0f);
    }];
    
    
    
    
    
    
    
    
}

-(void)layoutSubviews {
    [super layoutSubviews];
}

#pragma mark - Getter & Setter

@end
